package net.htjs.juc.waitnotify;

public class Demo3 {

    static final Object lock = new Object();

    /**
     * 不写synchronized方法直接调用对象的wait方法会报错
     * Exception in thread "main" java.lang.IllegalMonitorStateException: current thread is not owner
     * 	at java.base/java.lang.Object.wait(Native Method)
     * 	at java.base/java.lang.Object.wait(Object.java:338)
     * 	at net.htjs.juc.waitnotify.Demo3.main(Demo3.java:8)
     * @param args
     */
    public static void main(String[] args) {
        try {
            lock.wait();
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
    }
}
